import axios from 'axios'
//import config from "vue/src/core/config";

const request = axios.create({
    baseURL: 'http://localhost:9090',
    timeout: 5000
})

// request拦截器
// 可以自请求发送前对请求做一些处理
// 统一加token，对请求参数进行统一加密
request.interceptors.request.use(config => {
        config.headers['Content-Type'] = 'application/json;charset=utf-8';
        return config
    }, error => {
        return Promise.reject(error)
    }
);

request.interceptors.response.use(
    response => {
        let res = response.data;
        if (typeof res === 'string') {
            res = res ? JSON.parse(res) : res
        }
        return res;
    },
    error => {
        console.log('err'+error)
        return Promise.reject(error)
    }
)


export default request